import Vue from "vue";
// import "vant/lib/index.css";
import App from "./App.vue";
import router from "./router/index";
// import "@/assets/style/font/iconfont.css";
import "@/assets/style/index.less";
import $axios from "@/utils/request";
import mixin from "./mixin/index";
import store from "./store/index";
import { Switch } from 'vant'
import { Sidebar, SidebarItem } from 'vant';
import { Collapse, CollapseItem } from 'vant';
import { Picker } from 'vant';
import { CountDown } from 'vant';
import { DatetimePicker } from 'vant';
import { Area } from 'vant';
import { Toast } from 'vant';
import { PullRefresh } from 'vant';
import { Dialog } from 'vant';
import { Loading  } from 'vant';
import "@/components/Vant";
import { Overlay } from 'vant';
import wechat from '@/utils/payWx' 
import backItem from './components/backItem.vue'
import backImg from './components/backImg.vue'
if(wechat.isWechat()){  
    Vue.prototype.$wechat = wechat;  
}  
// rem
import "amfe-flexible";
// 把变量挂载到vue的原型上
Vue.prototype.$axios = $axios;
Vue.use(Switch);
Vue.use(Sidebar);
Vue.use(SidebarItem);
Vue.use(Collapse).use(CollapseItem);
Vue.use(Picker);
Vue.use(CountDown);
Vue.use(DatetimePicker);
Vue.use(Area);
Vue.use(Toast);
Vue.use(PullRefresh);
Vue.use(Overlay);
Vue.use(Dialog);
Vue.use(Loading);
Vue.mixin(mixin);
Vue.component('backItem', backItem)
Vue.component('backImg', backImg)

Vue.config.productionTip = false;

Vue.directive('myTitle', {
  inserted: function (el, binding) {
    const { value } = binding
    // 方式1，直接给v-myTitle标签的 data-title 属性赋值
    if (el.dataset.title) { 
      document.title = el.dataset.title
    } 
    // 方式2，通过指令传参（{{xxx}}）
    else if (value && value.title) { 
      document.title = value.title
    }
  },
  update (el, binding) {
    const { value } = binding
    if (el.dataset.title) {
      document.title = el.dataset.title
    } else if (value && value.title) {
      document.title = value.title
    }
  }
})


new Vue({
  store,
  router,
  render: h => h(App)
}).$mount("#app");
